#include <iostream>
#include <vector>

using namespace std;

double findMedianSortedArrays(vector<int>& nums1, vector<int>& nums2) {
    if (nums1.size() > nums2.size())
    {
        vector<int> tmp = nums1;
        nums1 = nums2;
        nums2 = tmp;
    }
    int m = nums1.size(), n = nums2.size();
    int totalLeft = (m + n + 1) / 2;
    int left = 0, right = m;
    while (left < right)
    {
        int i = left + (right - left + 1) / 2;
        int j = totalLeft - i;
        if (nums1[i - 1] > nums2[j])
            right = i - 1;
        else
            left = i;
    }
    int i = left, j = totalLeft - i;
    int num1LeftMax = i == 0 ? INT_MIN : nums1[i - 1];
    int num1RightMin = i == m ? INT_MAX : nums1[i];
    int num2LeftMax = j == 0 ? INT_MIN : nums2[j - 1];
    int num2RightMin = j == n ? INT_MAX : nums2[j];

    if ((m + n) % 2 == 1)
        return max(num1LeftMax, num2LeftMax);
    else
        return (double)((max(num1LeftMax, num2LeftMax) + min(num1RightMin, num2RightMin))) / 2;
}

int main()
{

	return 0;
}